Skip to content

Conversation

@rileyseaburg
Copy link
Contributor

Summary

Addresses code review feedback from PR #1925:

Changes

  1. Fix element_selector handling (template_renderer.rs)

    • Added null check for element_selector before calling getElementById
    • Prevents potential JavaScript errors with empty/null selectors
  2. Remove unnecessary cargo clean (extconf.rb)

    • Removed cargo clean call before build
    • Clean CI environment doesn't need cargo clean, and removing cached artifacts significantly increases build time
  3. Extract mock request setup to helper method (form.rb)

    • Created build_controller_with_mock_request private method
    • Reduces code duplication between touchpoints_js_string and render_widget_css
    • Improves maintainability

Not Addressed (Out of Scope)

  • Sleep in specs - Would require broader refactoring of test patterns
  • Production migrations - Intentional design decision (migrations run separately)
  • Sidekiq deploy strategy - Would require broader deployment architecture changes
  • Staging rake task syntax - Would need verification in staging environment

1. Fix element_selector handling in template_renderer.rs
   - Added null check for element_selector before calling getElementById
   - Prevents potential JS errors with empty/null selectors

2. Remove unnecessary cargo clean from extconf.rb
   - Removing cached artifacts significantly increases build time
   - Clean CI environment doesn't need cargo clean before build

3. Extract mock request setup to helper method in form.rb
   - Created build_controller_with_mock_request private method
   - Reduces code duplication between touchpoints_js_string and render_widget_css
   - Improves maintainability
Copilot AI review requested due to automatic review settings December 22, 2025 15:27
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses code review feedback from PR #1925 by fixing element selector handling, removing unnecessary cargo clean operations, and refactoring duplicated code in the Form model.

Key Changes:

  • Added null/empty check for element_selector before JavaScript getElementById call
  • Removed cargo clean command from Ruby extension build process to improve CI build performance
  • Extracted mock request setup logic into a reusable private helper method

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
ext/widget_renderer/src/template_renderer.rs Adds null check for element_selector to prevent JavaScript errors with empty selectors
ext/widget_renderer/extconf.rb Removes unnecessary cargo clean call to improve build performance in clean CI environments
app/models/form.rb Extracts duplicated mock request setup code into a private helper method for better maintainability

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Empty string '' is truthy in JavaScript when interpolated from Rust.
Use length check to properly handle empty element_selector values.
@rileyseaburg rileyseaburg merged commit 92d4e38 into develop Dec 22, 2025
4 of 5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants